/************************************************************************
int calc_design (int N, int L, int pathway[L][N], int mode, int mode1, int mode2, int irflag, int bdflag, int dgflag, int svflag, int pnflag, struct designability *designability, double Links_dist[N * N + 1], double Degree_dist[2 * N * N + 1], struct solution *solution)

Input

N	number of nodes
L	number of steps
pathway	process
mode	0 Process with steady state ; 1 Cycle Process ; 2 Triggled Cycle Process
mode1	0 Budding Yeast Model ; 1 Fission Yeast Model (with self-activation)
mode2	0 Traditional SIM ; 1 Restriction I ; 2 Restriction II ; 3 Restriciton I and II
irflag	1 irreducible solution only
bdflag	1 breakdown the designability by number of the links
dgflag	1/2 breakdown the designability by number of the degrees(r<->g is counted for 2)
svflag	1 save all solutions into the struct solution
pnflag	1 print the solutions

Output

designability
Links_dist
Degree_dist
solution

Return Value	1 : Feasible

Attn            Links_dist, Degree_dist and the member NS2/min_link in the structure designability need to allocate memory space before calling this function. Links_dist's size is N*N+1, Degree_dist's is 2*N*N+1, NS2/min_link's is N and store the number of solution / minimum number of link in the solution for each node.
Attn2           For structure array solution[], just need call init_solution function for each element once before calling calc_design. main2.c is an example about how to use this new feature.
***********************************************************************/

#include <stdlib.h>

struct designability {
	double NS;
	int *NS2, NS2_min;
	int *min_link, min_links;
	double *disqualifydist;
	int meddist;
};

struct solution {
	int max;
	int curr;
	int *edge; /* edge[n*N], ..., edge[(n+1)*N-1] save the nth solution */
	int *disqualify; /* flag the normal solution qualify the restriction or not*/
	int *count /* count[0] --- count[L-1] : count for disqualify */;
};

void init_solution (struct solution *solution);

void free_solution (struct solution *solution);

int calc_design (int N, int L, int pathway[L][N], int mode, int mode1, int mode2, int irflag, int bdflag, int dgflag, int svflag, int pnflag, struct designability *designability, double Links_dist[N * N + 1], double Degree_dist[2 * N * N + 1], struct solution *solution);
